/*
 ****************** 说明 **********************
 * Experimental program for FSSJ
 * CASE 1: FSSJ|noAccident|minDifference
 *         
 */
 
#include <stdio.h>
#include <iostream>
#include "cmodel.h"
#include "cmachine.h"
#include "cbuffer.h"
#include "cpart.h"


using namespace std;

#include "lib.h"

extern int O_1[C_out+1][M+1];	//工艺矩阵，类别i在机器j上的工序编号

extern int p_[NR+1];				//工序i的加工时间，

extern int s_[NR+1][NR+1];		//工序i到j的切换时间

extern int 	R_0_c[n_0+1];	//需求序列类别号码
extern double 	R_0_d[n_0+1];	//需求序列交货期

int main(int argc, char **argv)
{
	set_data();
	
	CModel FlowShop;
	CBuffer B0;
	CMachine M1;
	CBuffer B1;
	CMachine M2;
	CBuffer B2;
	
	FlowShop.AddElement(&B0);
	FlowShop.AddElement(&M1);
	FlowShop.AddElement(&B1);
	FlowShop.AddElement(&M2);
	FlowShop.AddElement(&B2);
	
	M1.AddPreviousElement(&B0);
	M1.AddNextElement(&B1);
	M1.setMachineID(1);
	
	M2.AddPreviousElement(&B1);
	M2.AddNextElement(&B2);
	M2.setMachineID(2);
	
	CPart part[n_0];
	
	for(int i=0;i<n_0;i++)
	{
		part[i].setDueTime(R_0_d[i+1]);
		part[i].setFinalType(R_0_c[i+1]);
		//
		B0.GetAPartIn(&part[i]);
	}
	
	//////////////////////////////
	FlowShop.Run();
	
	B2.showContent();
	B2.showDeltaTd();
	///////////////////////////////
	return 0;
}
